package diy;
//测试 向上转型和向下强转
public class T3 {
    public static void main(String[] args) {
        Animal2 a = new Dog2();
        if(a instanceof Cat2){
            Cat2 c = (Cat2) a;//编译可以通过，但运行会报错。两者不是父类和子类的关系，不能强转、
        }


    }
}
class Animal2{
    public void eat(){
        System.out.println("吃");
    }
    public void sleep(){
        System.out.println("睡");
    }
}
class Dog2 extends Animal2{

}
class Cat2 extends Animal2{

}